/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __D6C41EE7_119F_4261_A888_2BBC083D0F5B__
#define __D6C41EE7_119F_4261_A888_2BBC083D0F5B__

#include "../tools/head.h"

namespace xos_xml
{

    class doc_impl : public xos_stl::mem_item< xos::release_impl< doc_impl >, thread_lock >,
		public i_xml_doc
    {
    public:
        typedef xos::release_impl< doc_impl > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        static int get_xos_item_data( ITEM_DATA*& item_ptr );

    public:
        doc_impl();
        ~doc_impl();

    public:
        // 
        // 载入XML
        // 
        int load_xml_string( const char * lpszXml );
        int load_xml_file( const char * lpszXml );

        // 
        // 保存XML
        // 
        int save_xml_string( char * lpszXml, int nLen, int * lpnLenNeeded );
        int save_xml_file( const char * lpszFile );

        // 
        // 返回根节点
        // 
        int get_root_node( i_xml_node ** ppv );

        // 
        // 创建节点
        // 
        int create_and_append_node( const char * lpszNodeName, i_xml_node ** ppv );
        int create_node( const char * lpszNodeName, i_xml_node ** ppv );
        int append_node( i_xml_node * pv );
        int remove_node( i_xml_node * pv );

    public:
        int init();
        int term();

    protected:
        TiXmlDocument m_doc;

    };

} // xos_xml

#endif // __D6C41EE7_119F_4261_A888_2BBC083D0F5B__
